<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <title>统一地图平台</title><link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <style>
        html,
        body,
        #mapui {
            width: 100%;
            height: 100%;
        }

        html,
        body {
            margin: 0;
            padding: 0;
        }
    </style>
</head>

<body>
    <div id="mapui"></div>
    <script src="./js_example/script/map.min.js"></script>
    <script src="./js_example/script/demo.js"></script>

    <button type="button" onclick="ok()" style="position: absolute;top: 10px;right: 10px;">完成</button>
    <button type="button" onclick="cancel()" style="position: absolute;top: 10px;right: 60px;">取消</button>
    <button type="button" onclick="back()" style="position: absolute;top: 10px;right: 120px;">回退</button>
    <button type="button" onclick="point()" style="position: absolute;top: 10px;right: 180px;">绘点</button>
    <button type="button" onclick="line()" style="position: absolute;top: 10px;right: 240px;">绘线</button>
    <button type="button" onclick="polygon()" style="position: absolute;top: 10px;right: 300px;">绘面</button>
    <button type="button" onclick="edit()" style="position: absolute;top: 10px;right: 360px;">重新编辑</button>
    
    <script>
        var amap = null;
        var draw = null;

        map.Factory.create('mapui', {
            style : style,
            center: center,
            zoom: 10,
            strategy: ['mapboxgl', 'openlayers', 'leaflet'],
            fullExtent: {
                xmin: 108.23365,
                ymin: 17.95253,
                xmax: 111.78395,
                ymax: 20.13104
            },
            controls: []
        }, (o) => {
            amap = o;
            draw = map.Factory.Draw();
           
        });

        function ok() {
            var geom = draw.getGeometry();
            draw.end();
            draw.clear();
        }

        function cancel() {
            draw.end();
            draw.clear();
        }

        function back() {
            draw.delPoint();
        }

        function polygon() {
            draw.start('polygon');
        }

        function line() {
            draw.start('line');
        }

        function point() {
            draw.start('point');
        }

        function edit() {
            var line = {
                "type": "Feature",
                "properties": {},
                "geometry": {
                    "type": "LineString",
                    "coordinates": [
                        [113.292646, 23.101359],
                        [113.4022646, 23.201359]
                    ]
                }
            };
            draw.edit(line);
        }
    </script>
</body>

</html>